Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Self-modifying code</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Self-modifying_code"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Self-modifying_code rootpage-Self-modifying_code skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Self-modifying code</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1305433154">
/* start https://en.wikipedia.org/ */


.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style>
<p class="mw-empty-elt">


</p><p>In <a href="Computer_science" title="Computer science">computer science</a>, <b>self-modifying code</b> (<b>SMC</b> or <b>SMoC</b>) is <a href="Source_code" title="Source code">code</a> that alters its own <a href="Instruction_(computer_science)" class="mw-redirect" title="Instruction (computer science)">instructions</a> while it is <a href="Execution_(computing)" title="Execution (computing)">executing</a> – usually to reduce the <a href="Instruction_path_length" title="Instruction path length">instruction path length</a> and improve <a href="Computer_performance" title="Computer performance">performance</a> or simply to reduce otherwise <a href="Duplicate_code" title="Duplicate code">repetitively similar code</a>, thus simplifying <a href="Software_maintenance" title="Software maintenance">maintenance</a>. The term is usually only applied to code where the self-modification is intentional, not in situations where code accidentally modifies itself due to an error such as a <a href="Buffer_overflow" title="Buffer overflow">buffer overflow</a>.
</p><p>Self-modifying code can involve overwriting existing instructions or generating new code at run time and transferring control to that code.
</p><p>Self-modification can be used as an alternative to the method of "flag setting" and conditional program branching, used primarily to reduce the number of times a condition needs to be tested.
</p><p>The method is frequently used for conditionally invoking <a href="Test/debugging" class="mw-redirect" title="Test/debugging">test/debugging</a> code without requiring additional <a href="Computational_overhead" class="mw-redirect" title="Computational overhead">computational overhead</a> for every <a href="Input/output" title="Input/output">input/output</a> cycle.
</p><p>The modifications may be performed:
</p>
<ul><li><b>only during initialization</b> – based on input <a href="Parameter#Computing" title="Parameter">parameters</a> (when the process is more commonly described as software '<a href="Computer_configuration" title="Computer configuration">configuration</a>' and is somewhat analogous, in hardware terms, to setting <a href="Jumper_(computing)" title="Jumper (computing)">jumpers</a> for <a href="Printed_circuit_board" title="Printed circuit board">printed circuit boards</a>). Alteration of program entry <a href="Pointer_(computer_programming)" title="Pointer (computer programming)">pointers</a> is an equivalent indirect method of self-modification, but requiring the co-existence of one or more alternative instruction paths, increasing the <a href="Binary_file" title="Binary file">program size</a>.</li>
<li><b>throughout execution</b> ("on the fly") – based on particular program states that have been reached during the execution</li></ul>
<p>In either case, the modifications may be performed directly to the <a href="Machine_code" title="Machine code">machine code</a> instructions themselves, by <a href="Overlapping_instructions" class="mw-redirect" title="Overlapping instructions">overlaying</a> new instructions over the existing ones (for example: altering a compare and branch to an <a href="Unconditional_branch" class="mw-redirect" title="Unconditional branch">unconditional branch</a> or alternatively a '<a href="NOP_(code)" title="NOP (code)">NOP</a>').
</p><p>In the <a href="IBM_System/360_architecture" title="IBM System/360 architecture">IBM System/360 architecture</a>, and its successors up to <a href="Z/Architecture" title="Z/Architecture">z/Architecture</a>, an EXECUTE (EX) instruction <i>logically</i> overlays the second byte of its target instruction with the low-order 8 bits of <a href="General-purpose_register" class="mw-redirect" title="General-purpose register">register</a> 1. This provides the effect of self-modification although the actual instruction in storage is not altered.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Application_in_low_and_high_level_languages">Application in low and high level languages</h2></div>
<p>Self-modification can be accomplished in a variety of ways depending upon the programming language and its support for pointers and/or access to dynamic compiler or interpreter 'engines':
</p>
<ul><li><b>overlay of existing instructions</b> (or parts of instructions such as opcode, register, flags or addresses) or</li>
<li><b>direct creation of whole instructions</b> or sequences of instructions in memory</li>
<li><b>creation or modification of <a href="Source_code" title="Source code">source code</a> statements</b> followed by a 'mini compile' or a dynamic interpretation (see <a href="Eval" title="Eval">eval</a> statement)</li>
<li><b>creating an entire program dynamically</b> and then executing it</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Assembly_language">Assembly language</h3></div>
<p>Self-modifying code is quite straightforward to implement when using <a href="Assembly_language" title="Assembly language">assembly language</a>. Instructions can be dynamically created in <a href="Computer_memory" title="Computer memory">memory</a> (or else overlaid over existing code in non-protected program storage),<sup id="cite_ref-HP9100A_1998_1-0" class="reference"><a href="#cite_note-HP9100A_1998-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> in a sequence equivalent to the ones that a standard compiler may generate as the <a href="Object_code" title="Object code">object code</a>. With modern processors, there can be unintended <a href="Side_effect_(computer_science)" title="Side effect (computer science)">side effects</a> on the <a href="CPU_cache" title="CPU cache">CPU cache</a> that must be considered. The method was frequently used for testing 'first time' conditions, as in this suitably commented <a href="IBM/360" class="mw-redirect" title="IBM/360">IBM/360</a> <a href="Assembler_(computer_programming)" class="mw-redirect" title="Assembler (computer programming)">assembler</a> example. It uses instruction overlay to reduce the <a href="Instruction_path_length" title="Instruction path length">instruction path length</a> by (N×1)−1 where N is the number of records on the file (−1 being the <a href="Computational_overhead" class="mw-redirect" title="Computational overhead">overhead</a> to perform the overlay).
</p>
<pre>SUBRTN NOP OPENED FIRST TIME HERE?
* The NOP is x'4700'&lt;Address_of_opened&gt;
OI SUBRTN+1,X'F0' YES, CHANGE NOP TO UNCONDITIONAL BRANCH (47F0...)
OPEN INPUT AND OPEN THE INPUT FILE SINCE IT'S THE FIRST TIME THRU
OPENED GET INPUT NORMAL PROCESSING RESUMES HERE
...
</pre>
<p>Alternative code might involve testing a "flag" each time through. The unconditional branch is slightly faster than a compare instruction, as well as reducing the overall path length. In later operating systems for programs residing in <a href="Memory_protection" title="Memory protection">protected storage</a> this technique could not be used and so changing the pointer to the <a href="Subroutine" class="mw-redirect" title="Subroutine">subroutine</a> would be used instead. The pointer would reside in <a href="Dynamic_storage" class="mw-redirect" title="Dynamic storage">dynamic storage</a> and could be altered at will after the first pass to bypass the OPEN (having to load a pointer first instead of a direct branch &amp; link to the subroutine would add N instructions to the path length&nbsp;– but there would be a corresponding reduction of N for the unconditional branch that would no longer be required).
</p><p>Below is an example in <a href="Zilog_Z80" title="Zilog Z80">Zilog Z80</a> assembly language. The code increments register "B" in range [0,5]. The "CP" compare instruction is modified on each loop.
</p>
<div class="mw-highlight mw-highlight-lang-nasm mw-content-ltr" dir="ltr"><pre><span class="c1">;==========</span>
<span class="k">ORG</span><span class="w"> </span><span class="mh">0H</span>
<span class="nf">CALL</span><span class="w"> </span><span class="nv">FUNC00</span>
<span class="nf">HALT</span>
<span class="c1">;==========</span>
<span class="nl">FUNC00:</span>
<span class="nf">LD</span><span class="w"> </span><span class="nv">A</span><span class="p">,</span><span class="mi">6</span>
<span class="nf">LD</span><span class="w"> </span><span class="nv">HL</span><span class="p">,</span><span class="nv">label01</span><span class="o">+</span><span class="mi">1</span>
<span class="nf">LD</span><span class="w"> </span><span class="nv">B</span><span class="p">,(</span><span class="nv">HL</span><span class="p">)</span>
<span class="nl">label00:</span>
<span class="nf">INC</span><span class="w"> </span><span class="nv">B</span>
<span class="nf">LD</span><span class="w"> </span><span class="p">(</span><span class="nv">HL</span><span class="p">),</span><span class="nv">B</span>
<span class="nl">label01:</span>
<span class="nf">CP</span><span class="w"> </span><span class="kc">$</span><span class="mi">0</span>
<span class="nf">JP</span><span class="w"> </span><span class="nv">NZ</span><span class="p">,</span><span class="nv">label00</span>
<span class="nf">RET</span>
<span class="c1">;==========</span>
</pre></div>
<p>Self-modifying code is sometimes used to overcome limitations in a machine's instruction set. For example, in the <a href="Intel_8080" title="Intel 8080">Intel 8080</a> instruction set, one cannot input a byte from an input port that is specified in a register. The input port is statically encoded in the instruction itself, as the second byte of a two byte instruction. Using self-modifying code, it is possible to store a register's contents into the second byte of the instruction, then execute the modified instruction in order to achieve the desired effect.
</p>
<div class="mw-heading mw-heading3"><h3 id="High-level_languages">High-level languages</h3></div>
<p>Some compiled languages explicitly permit self-modifying code. For example, the ALTER verb in <a href="COBOL" title="COBOL">COBOL</a> may be implemented as a branch instruction that is modified during execution.<sup id="cite_ref-MicroFocus_ALTER_2-0" class="reference"><a href="#cite_note-MicroFocus_ALTER-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> Some <a href="Batch_file" title="Batch file">batch</a> programming techniques involve the use of self-modifying code. <a href="Clipper_(programming_language)" title="Clipper (programming language)">Clipper</a> and <a href="SPITBOL" title="SPITBOL">SPITBOL</a> also provide facilities for explicit self-modification. The Algol compiler on <a href="Burroughs_Large_Systems" title="Burroughs Large Systems">B6700 systems</a> offered an interface to the operating system whereby executing code could pass a text string or a named disc file to the Algol compiler and was then able to invoke the new version of a procedure.
</p><p>With interpreted languages, the "machine code" is the source text and may be susceptible to editing on-the-fly: in <a href="SNOBOL" title="SNOBOL">SNOBOL</a> the source statements being executed are elements of a text array. Other languages, such as <a href="Perl" title="Perl">Perl</a> and <a href="Python_(programming_language)" title="Python (programming language)">Python</a>, allow programs to create new code at run-time and execute it using an <a href="Eval" title="Eval">eval</a> function, but do not allow existing code to be mutated. The illusion of modification (even though no machine code is really being overwritten) is achieved by modifying function pointers, as in this JavaScript example:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">f</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="p">(</span><span class="nx">x</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="k">return</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">1</span><span class="p">};</span>

<span class="w"> </span><span class="c1">// assign a new definition to f:</span>
<span class="w"> </span><span class="nx">f</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nb">Function</span><span class="p">(</span><span class="s1">'x'</span><span class="p">,</span><span class="w"> </span><span class="s1">'return x + 2'</span><span class="p">);</span>
</pre></div>
<p><a href="Lisp_macro" class="mw-redirect" title="Lisp macro">Lisp macros</a> also allow runtime code generation without parsing a string containing program code.
</p><p>The Push programming language is a <a href="Genetic_programming" title="Genetic programming">genetic programming</a> system that is explicitly designed for creating self-modifying programs. While not a high level language, it is not as low level as assembly language.<sup id="cite_ref-Push_3-0" class="reference"><a href="#cite_note-Push-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Compound_modification">Compound modification</h4></div>
<p>Prior to the advent of multiple windows, command-line systems might offer a menu system involving the modification of a running command script. Suppose a <a href="DOS" title="DOS">DOS</a> script (or "batch") file MENU.BAT contains the following:<sup id="cite_ref-Fosdal_2001_4-0" class="reference"><a href="#cite_note-Fosdal_2001-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-NB_CHOICE_5-0" class="reference"><a href="#cite_note-NB_CHOICE-5"><span class="cite-bracket">[</span>nb 1<span class="cite-bracket">]</span></a></sup>
</p>
<pre> :start
SHOWMENU.EXE
</pre>
<p>Upon initiation of MENU.BAT from the command line, SHOWMENU presents an on-screen menu, with possible help information, example usages and so forth. Eventually the user makes a selection that requires a command <i>SOMENAME</i> to be performed: SHOWMENU exits after rewriting the file MENU.BAT to contain
</p>
<pre> :start
SHOWMENU.EXE
CALL <i>SOMENAME</i>.BAT
GOTO start
</pre>
<p>Because the DOS command interpreter does not compile a script file and then execute it, nor does it read the entire file into memory before starting execution, nor yet rely on the content of a record buffer, when SHOWMENU exits, the command interpreter finds a new command to execute (it is to invoke the script file <i>SOMENAME</i>, in a directory location and via a protocol known to SHOWMENU), and after that command completes, it goes back to the start of the script file and reactivates SHOWMENU ready for the next selection. Should the menu choice be to quit, the file would be rewritten back to its original state. Although this starting state has no use for the label, it, or an equivalent amount of text is required, because the DOS command interpreter recalls the byte position of the next command when it is to start the next command, thus the re-written file must maintain alignment for the next command start point to indeed be the start of the next command.
</p><p>Aside from the convenience of a menu system (and possible auxiliary features), this scheme means that the SHOWMENU.EXE system is not in memory when the selected command is activated, a significant advantage when memory is limited.<sup id="cite_ref-Fosdal_2001_4-1" class="reference"><a href="#cite_note-Fosdal_2001-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Paul_1996_6-0" class="reference"><a href="#cite_note-Paul_1996-6"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Control_tables">Control tables</h3></div>
<p><a href="Control_table" title="Control table">Control table</a> <a href="Interpreter_(computing)" title="Interpreter (computing)">interpreters</a> can be considered to be, in one sense, 'self-modified' by data values extracted from the table entries (rather than specifically <a href="Hand_coding" title="Hand coding">hand coded</a> in <a href="Conditional_(computer_programming)" title="Conditional (computer programming)">conditional statements</a> of the form "IF inputx = 'yyy'").
</p>
<div class="mw-heading mw-heading3"><h3 id="Channel_programs">Channel programs</h3></div>
<p>Some IBM <a href="Access_method" title="Access method">access methods</a> traditionally used self-modifying <a href="Channel_I/O#Channel_program" title="Channel I/O">channel programs</a>, where a value, such as a disk address, is read into an area referenced by a channel program, where it is used by a later channel command to access the disk.
</p>
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<p>The <a href="IBM_SSEC" title="IBM SSEC">IBM SSEC</a>, demonstrated in January 1948, had the ability to modify its instructions or otherwise treat them exactly like data. However, the capability was rarely used in practice.<sup id="cite_ref-Bashe-Buchholz-Hawkins-Ingram-Rochester_1981_7-0" class="reference"><a href="#cite_note-Bashe-Buchholz-Hawkins-Ingram-Rochester_1981-7"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> In the early days of computers, self-modifying code was often used to reduce use of limited memory, or improve performance, or both. It was also sometimes used to implement subroutine calls and returns when the instruction set only provided simple branching or skipping instructions to vary the <a href="Control_flow" title="Control flow">control flow</a>.<sup id="cite_ref-Miller_2006_8-0" class="reference"><a href="#cite_note-Miller_2006-8"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Wenzl-Merzdovnik-Ullrich-Weippl_2019_9-0" class="reference"><a href="#cite_note-Wenzl-Merzdovnik-Ullrich-Weippl_2019-9"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> This use is still relevant in certain ultra-<a href="Reduced_instruction_set_computer" title="Reduced instruction set computer">RISC</a> architectures, at least theoretically; see for example <a href="One-instruction_set_computer" title="One-instruction set computer">one-instruction set computer</a>. <a href="Donald_Knuth" title="Donald Knuth">Donald Knuth</a>'s <a href="MIX_(abstract_machine)" title="MIX (abstract machine)">MIX</a> architecture also used self-modifying code to implement subroutine calls.<sup id="cite_ref-Knuth_MMIX_10-0" class="reference"><a href="#cite_note-Knuth_MMIX-10"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Usage">Usage</h2></div>
<p>Self-modifying code can be used for various purposes:
</p>
<ul><li>Semi-automatic <a href="Program_optimization" title="Program optimization">optimizing</a> of a state-dependent loop.</li>
<li>Dynamic in-place code optimization for speed depending on load environment.<sup id="cite_ref-Caldera_1997_DOSSRC_11-0" class="reference"><a href="#cite_note-Caldera_1997_DOSSRC-11"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Paul_1997_OD-A3_12-0" class="reference"><a href="#cite_note-Paul_1997_OD-A3-12"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-NB_DR-DOS_386_13-0" class="reference"><a href="#cite_note-NB_DR-DOS_386-13"><span class="cite-bracket">[</span>nb 2<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Run_time_(program_lifecycle_phase)" class="mw-redirect" title="Run time (program lifecycle phase)">Run-time</a> code generation, or specialization of an algorithm in runtime or loadtime (which is popular, for example, in the domain of real-time graphics) such as a general sort utility&nbsp;– preparing code to perform the key comparison described in a specific invocation.</li>
<li>Altering of <a href="Inline_function" class="mw-redirect" title="Inline function">inlined</a> state of an <a href="Object_(computer_science)" title="Object (computer science)">object</a>, or simulating the high-level construction of <a href="Closure_(computer_programming)" title="Closure (computer programming)">closures</a>.</li>
<li>Patching of <a href="Subroutine" class="mw-redirect" title="Subroutine">subroutine</a> (<a href="Pointer_(computer_programming)" title="Pointer (computer programming)">pointer</a>) address calling, usually as performed at load/initialization time of <a href="Dynamic_libraries" class="mw-redirect" title="Dynamic libraries">dynamic libraries</a>, or else on each invocation, patching the subroutine's internal references to its parameters so as to use their actual addresses (i.e. indirect self-modification).</li>
<li>Evolutionary computing systems such as <a href="Neuroevolution" title="Neuroevolution">neuroevolution</a>, <a href="Genetic_programming" title="Genetic programming">genetic programming</a> and other <a href="Evolutionary_algorithm" title="Evolutionary algorithm">evolutionary algorithms</a>.</li>
<li>Hiding of code to prevent <a href="Reverse_engineering" title="Reverse engineering">reverse engineering</a> (by use of a <a href="Disassembler" title="Disassembler">disassembler</a> or <a href="Debugger" title="Debugger">debugger</a>) or to evade detection by virus/spyware scanning software and the like.</li>
<li>Filling 100% of memory (in some architectures) with a rolling pattern of repeating <a href="Opcode" title="Opcode">opcodes</a>, to erase all programs and data, or to <a href="Burn-in" title="Burn-in">burn-in</a> hardware or perform <a href="RAM_test" class="mw-redirect" title="RAM test">RAM tests</a>.<sup id="cite_ref-Wilkinson_1996_14-0" class="reference"><a href="#cite_note-Wilkinson_1996-14"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Executable_compression" title="Executable compression">Compressing</a> code to be decompressed and executed at runtime, e.g., when memory or disk space is limited.<sup id="cite_ref-Caldera_1997_DOSSRC_11-1" class="reference"><a href="#cite_note-Caldera_1997_DOSSRC-11"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Paul_1997_OD-A3_12-1" class="reference"><a href="#cite_note-Paul_1997_OD-A3-12"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup></li>
<li>Some very limited <a href="Instruction_set_architecture" title="Instruction set architecture">instruction sets</a> leave no option but to use self-modifying code to perform certain functions. For example, a <a href="One-instruction_set_computer" title="One-instruction set computer">one-instruction set computer</a> (OISC) machine that uses only the subtract-and-branch-if-negative "instruction" cannot do an indirect copy (something like the equivalent of "*a = **b" in the <a href="C_(programming_language)" title="C (programming language)">C language</a>) without using self-modifying code.</li>
<li><a href="Booting" title="Booting">Booting</a>. Early <a href="Microcomputer" title="Microcomputer">microcomputers</a> often used self-modifying code in their bootloaders. Since the bootloader was keyed in via the front panel at every power-on, it did not matter if the <a href="Bootloader" title="Bootloader">bootloader</a> modified itself. However, even today many bootstrap loaders are <a href="Self-relocating" class="mw-redirect" title="Self-relocating">self-relocating</a>, and a few are even self-modifying.<sup id="cite_ref-NB_DR-DOS_707_15-0" class="reference"><a href="#cite_note-NB_DR-DOS_707-15"><span class="cite-bracket">[</span>nb 3<span class="cite-bracket">]</span></a></sup></li>
<li>Altering instructions for fault-tolerance.<sup id="cite_ref-Ortiz_2015_16-0" class="reference"><a href="#cite_note-Ortiz_2015-16"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup></li></ul>
<div class="mw-heading mw-heading3"><h3 id="Optimizing_a_state-dependent_loop">Optimizing a state-dependent loop</h3></div>
<p><a href="Pseudocode" title="Pseudocode">Pseudocode</a> example:
</p>
<pre>repeat <i>N</i> times {
if STATE is 1
increase A by one
else
decrease A by one
do something with A
}
</pre>
<p>Self-modifying code, in this case, would simply be a matter of rewriting the loop like this:
</p>
<pre>repeat <i>N</i> times {
<i>increase</i> A by one
do something with A
when STATE has to switch {
replace the opcode "increase" above with the opcode to decrease, or vice versa
}
}
</pre>
<p>Note that two-state replacement of the <a href="Opcode" title="Opcode">opcode</a> can be easily written as 'xor var at address with the value "opcodeOf(Inc) xor opcodeOf(dec)"'.
</p><p>Choosing this solution must depend on the value of <var style="padding-right: 1px;">N</var> and the frequency of state changing.
</p>
<div class="mw-heading mw-heading3"><h3 id="Specialization">Specialization</h3></div>
<p>Suppose a set of statistics such as average, extrema, location of extrema, standard deviation, etc. are to be calculated for some large data set. In a general situation, there may be an option of associating weights with the data, so each x<sub>i</sub> is associated with a w<sub>i</sub> and rather than test for the presence of weights at every index value, there could be two versions of the calculation, one for use with weights and one not, with one test at the start. Now consider a further option, that each value may have associated with it a Boolean to signify whether that value is to be skipped or not. This could be handled by producing four batches of code, one for each permutation and code bloat results. Alternatively, the weight and the skip arrays could be merged into a temporary array (with zero weights for values to be skipped), at the cost of processing and still there is bloat. However, with code modification, to the template for calculating the statistics could be added as appropriate the code for skipping unwanted values, and for applying weights. There would be no repeated testing of the options and the data array would be accessed once, as also would the weight and skip arrays, if involved.
</p>
<div class="mw-heading mw-heading3"><h3 id="Use_as_camouflage">Use as camouflage</h3></div>
<p>Self-modifying code is more complex to analyze than standard code and can therefore be used as a protection against <a href="Reverse_engineering" title="Reverse engineering">reverse engineering</a> and <a href="Software_cracking" title="Software cracking">software cracking</a>. Self-modifying code was used to hide copy protection instructions in 1980s disk-based programs for systems such as <a href="IBM_PC_compatible" title="IBM PC compatible">IBM PC compatibles</a> and <a href="Apple_II" title="Apple II">Apple II</a>. For example, on an IBM PC, the <a href="Floppy_disk" title="Floppy disk">floppy disk</a> drive access instruction <code><a href="Int_0x13" class="mw-redirect" title="Int 0x13">int 0x13</a></code> would not appear in the executable program's image but it would be written into the executable's memory image after the program started executing.
</p><p>Self-modifying code is also sometimes used by programs that do not want to reveal their presence, such as <a href="Computer_virus" title="Computer virus">computer viruses</a> and some <a href="Shellcode" title="Shellcode">shellcodes</a>. Viruses and shellcodes that use self-modifying code mostly do this in combination with <a href="Polymorphic_code" title="Polymorphic code">polymorphic code</a>. Modifying a piece of running code is also used in certain attacks, such as <a href="Buffer_overflow" title="Buffer overflow">buffer overflows</a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Self-referential_machine_learning_systems">Self-referential machine learning systems</h3></div>
<p>Traditional <a href="Machine_learning" title="Machine learning">machine learning</a> systems have a fixed, pre-programmed learning <a href="Algorithm" title="Algorithm">algorithm</a> to adjust their <a href="Parameter_(computer_programming)" title="Parameter (computer programming)">parameters</a>. However, since the 1980s <a href="J%C3%BCrgen_Schmidhuber" title="Jürgen Schmidhuber">Jürgen Schmidhuber</a> has published several self-modifying systems with the ability to change their own learning algorithm. They avoid the danger of catastrophic self-rewrites by making sure that self-modifications will survive only if they are useful according to a user-given <a href="Fitness_function" title="Fitness function">fitness</a>, <a href="Error_function" title="Error function">error</a> or <a href="Reward_function" class="mw-redirect" title="Reward function">reward</a> function.<sup id="cite_ref-Schmidhuber_17-0" class="reference"><a href="#cite_note-Schmidhuber-17"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Operating_systems">Operating systems</h3></div>
<p>The <a href="Linux_kernel" title="Linux kernel">Linux kernel</a> notably makes wide use of self-modifying code; it does so to be able to distribute a single binary image for each major architecture (e.g. <a href="IA-32" title="IA-32">IA-32</a>, <a href="X86-64" title="X86-64">x86-64</a>, 32-bit <a href="ARM_architecture_family" title="ARM architecture family">ARM</a>, <a href="ARM64" class="mw-redirect" title="ARM64">ARM64</a>...) while adapting the kernel code in memory during boot depending on the specific CPU model detected, e.g. to be able to take advantage of new CPU instructions or to work around hardware bugs.<sup id="cite_ref-linux_self_modifying_Paltsev_18-0" class="reference"><a href="#cite_note-linux_self_modifying_Paltsev-18"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-linux_self_modifying_altinstructions_19-0" class="reference"><a href="#cite_note-linux_self_modifying_altinstructions-19"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup> To a lesser extent, the <a href="DR-DOS" title="DR-DOS">DR-DOS</a> kernel also optimizes speed-critical sections of itself at loadtime depending on the underlying processor generation.<sup id="cite_ref-Caldera_1997_DOSSRC_11-2" class="reference"><a href="#cite_note-Caldera_1997_DOSSRC-11"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Paul_1997_OD-A3_12-2" class="reference"><a href="#cite_note-Paul_1997_OD-A3-12"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-NB_DR-DOS_386_13-1" class="reference"><a href="#cite_note-NB_DR-DOS_386-13"><span class="cite-bracket">[</span>nb 2<span class="cite-bracket">]</span></a></sup>
</p><p>Regardless, at a <a href="Meta-level" class="mw-redirect" title="Meta-level">meta-level</a>, programs can still modify their own behavior by changing data stored elsewhere (see <a href="Metaprogramming" title="Metaprogramming">metaprogramming</a>) or via use of <a href="Type_polymorphism" class="mw-redirect" title="Type polymorphism">polymorphism</a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Massalin's_Synthesis_kernel">Massalin's Synthesis kernel</h3></div>
<p>The Synthesis <a href="Kernel_(operating_system)" title="Kernel (operating system)">kernel</a> presented in <a href="Alexia_Massalin" title="Alexia Massalin">Alexia Massalin</a>'s <a href="Doctor_of_Philosophy" title="Doctor of Philosophy">Ph.D.</a> thesis<sup id="cite_ref-Massalin_1992_Synthesis_20-0" class="reference"><a href="#cite_note-Massalin_1992_Synthesis-20"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Henson_2008_21-0" class="reference"><a href="#cite_note-Henson_2008-21"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup> is a tiny <a href="Unix" title="Unix">Unix</a> kernel that takes a <a href="Structured_programming" title="Structured programming">structured</a>, or even <a href="Object-oriented_programming" title="Object-oriented programming">object oriented</a>, approach to self-modifying code, where code is created for individual <a href="Quaject" title="Quaject">quajects</a>, like filehandles. Generating code for specific tasks allows the Synthesis kernel to (as a JIT interpreter might) apply a number of <a href="Compiler_optimization" class="mw-redirect" title="Compiler optimization">optimizations</a> such as <a href="Constant_folding" title="Constant folding">constant folding</a> or <a href="Common_subexpression_elimination" title="Common subexpression elimination">common subexpression elimination</a>.
</p><p>The Synthesis kernel was very fast, but was written entirely in assembly. The resulting lack of portability has prevented Massalin's optimization ideas from being adopted by any production kernel. However, the structure of the techniques suggests that they could be captured by a higher level <a href="Programming_language" title="Programming language">language</a>, albeit one more complex than existing mid-level languages. Such a language and compiler could allow development of faster operating systems and applications.
</p><p><a href="Paul_Haeberli" title="Paul Haeberli">Paul Haeberli</a> and Bruce Karsh have objected to the "marginalization" of self-modifying code, and optimization in general, in favor of reduced development costs.<sup id="cite_ref-Haeberli_1994_GraficaObscura_22-0" class="reference"><a href="#cite_note-Haeberli_1994_GraficaObscura-22"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Interaction_of_cache_and_self-modifying_code">Interaction of cache and self-modifying code</h2></div>
<p>On architectures without coupled data and instruction cache (for example, some <a href="SPARC" title="SPARC">SPARC</a>, ARM, and <a href="MIPS_architecture" title="MIPS architecture">MIPS</a> cores) the cache synchronization must be explicitly performed by the modifying code (flush data cache and invalidate instruction cache for the modified memory area).
</p><p>In some cases short sections of self-modifying code execute more slowly on modern processors. This is because a modern processor will usually try to keep blocks of code in its cache memory. Each time the program rewrites a part of itself, the rewritten part must be loaded into the cache again, which results in a slight delay, if the modified codelet shares the same cache line with the modifying code, as is the case when the modified memory address is located within a few bytes to the one of the modifying code.
</p><p>The cache invalidation issue on modern processors usually means that self-modifying code would still be faster only when the modification will occur rarely, such as in the case of a state switching inside an inner loop.
</p><p>Most modern processors load the machine code before they execute it, which means that if an instruction that is too near the <a href="Instruction_pointer" class="mw-redirect" title="Instruction pointer">instruction pointer</a> is modified, the processor will not notice, but instead execute the code as it was <i>before</i> it was modified. See <a href="Prefetch_input_queue" title="Prefetch input queue">prefetch input queue</a> (PIQ). PC processors must handle self-modifying code correctly for backwards compatibility reasons but they are far from efficient at doing so.
</p>
<div class="mw-heading mw-heading2"><h2 id="Security_issues">Security issues</h2></div>
<p>Because of the security implications of self-modifying code, all of the major <a href="Operating_system" title="Operating system">operating systems</a> are careful to remove such vulnerabilities as they become known. The concern is typically not that programs will intentionally modify themselves, but that they could be maliciously changed by an <a href="Exploit_(computer_security)" title="Exploit (computer security)">exploit</a>.
</p><p>One mechanism for preventing malicious code modification is an operating system feature called <a href="W%5EX" title="W^X">W^X</a> (for "write <a href="Xor" class="mw-redirect" title="Xor">xor</a> execute"). This mechanism prohibits a program from making any page of memory both writable and executable. Some systems prevent a writable page from ever being changed to be executable, even if write permission is removed. Other systems provide a '<a href="Backdoor_(computing)" title="Backdoor (computing)">back door</a>' of sorts, allowing multiple mappings of a page of memory to have different permissions. A relatively portable way to bypass W^X is to create a file with all permissions, then map the file into memory twice. On Linux, one may use an undocumented SysV shared memory flag to get executable shared memory without needing to create a file.
</p>
<div class="mw-heading mw-heading2"><h2 id="Advantages">Advantages</h2></div>
<ul><li><a href="Fast_path" title="Fast path">Fast paths</a> can be established for a program's execution, reducing some otherwise repetitive <a href="Conditional_branch" class="mw-redirect" title="Conditional branch">conditional branches</a>.</li>
<li>Self-modifying code can improve <a href="Algorithmic_efficiency" title="Algorithmic efficiency">algorithmic efficiency</a>.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Disadvantages">Disadvantages</h2></div>
<p>Self-modifying code is harder to read and maintain because the instructions in the source program listing are not necessarily the instructions that will be executed. Self-modification that consists of substitution of <a href="Function_pointer" title="Function pointer">function pointers</a> might not be as cryptic, if it is clear that the names of functions to be called are placeholders for functions to be identified later.
</p><p>Self-modifying code can be rewritten as code that tests a <a href="Flag_(programming)" title="Flag (programming)">flag</a> and branches to alternative sequences based on the outcome of the test, but self-modifying code typically runs faster.
</p><p>Self-modifying code conflicts with authentication of the code and may require exceptions to policies requiring that all code running on a system be signed.
</p><p>Modified code must be stored separately from its original form, conflicting with memory management solutions that normally discard the code in RAM and reload it from the executable file as needed.
</p><p>On modern processors with an <a href="Instruction_pipelining" title="Instruction pipelining">instruction pipeline</a>, code that modifies itself frequently may run more slowly, if it modifies instructions that the processor has already read from memory into the pipeline. On some such processors, the only way to ensure that the modified instructions are executed correctly is to flush the pipeline and reread many instructions.
</p><p>Self-modifying code cannot be used at all in some environments, such as the following:
</p>
<ul><li>Application software running under an operating system with strict W^X security cannot execute instructions in pages it is allowed to write to—only the operating system is allowed to both write instructions to memory and later execute those instructions.</li>
<li>Many <a href="Harvard_architecture" title="Harvard architecture">Harvard architecture</a> <a href="Microcontroller" title="Microcontroller">microcontrollers</a> cannot execute instructions in read-write memory, but only instructions in memory that it cannot write to, ROM or non-self-programmable <a href="Flash_memory" title="Flash memory">flash memory</a>.</li>
<li>A multithreaded application may have several threads executing the same section of self-modifying code, possibly resulting in computation errors and application failures.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Overlapping_code" class="mw-redirect" title="Overlapping code">Overlapping code</a></li>
<li><a href="Polymorphic_code" title="Polymorphic code">Polymorphic code</a></li>
<li><a href="Polymorphic_engine" title="Polymorphic engine">Polymorphic engine</a></li>
<li><a href="Persistent_data_structure" title="Persistent data structure">Persistent data structure</a></li>
<li><a href="AARD_code" title="AARD code">AARD code</a></li>
<li><a href="Algorithmic_efficiency" title="Algorithmic efficiency">Algorithmic efficiency</a></li>
<li><a href="Data_as_code" class="mw-redirect" title="Data as code">Data as code</a></li>
<li><a href="Eval" title="Eval">eval</a> statement</li>
<li><a href="IBM_1130#Code_modification" title="IBM 1130">IBM 1130</a> (Example)</li>
<li><a href="Just-in-time_compilation" title="Just-in-time compilation">Just-in-time compilation</a>: This technique can often give users many of the benefits of self-modifying code (except memory size) without the disadvantages.</li>
<li><a href="Dynamic_dead_code_elimination" class="mw-redirect" title="Dynamic dead code elimination">Dynamic dead code elimination</a></li>
<li><a href="Homoiconicity" title="Homoiconicity">Homoiconicity</a></li>
<li><a href="PCASTL" title="PCASTL">PCASTL</a></li>
<li><a href="Quine_(computing)" title="Quine (computing)">Quine (computing)</a></li>
<li><a href="Self-replication" title="Self-replication">Self-replication</a></li>
<li><a href="Reflective_programming" title="Reflective programming">Reflective programming</a></li>
<li><a href="Monkey_patch" title="Monkey patch">Monkey patch</a>: a modification to runtime code that does not affect a program's original source code</li>
<li><a href="Extensible_programming" title="Extensible programming">Extensible programming</a>: a programming paradigm in which a programming language can modify its own syntax</li>
<li><a href="Self-modifying_computer_virus" class="mw-redirect" title="Self-modifying computer virus">Self-modifying computer virus</a></li>
<li><a href="Self-hosting_(compilers)" title="Self-hosting (compilers)">Self-hosting</a></li>
<li><a href="Synthetic_programming" class="mw-redirect" title="Synthetic programming">Synthetic programming</a></li>
<li><a href="Compiler_bootstrapping" class="mw-redirect" title="Compiler bootstrapping">Compiler bootstrapping</a></li>
<li><a href="Patchable_microcode" class="mw-redirect" title="Patchable microcode">Patchable microcode</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-NB_CHOICE-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-NB_CHOICE_5-0">^</a></b></span> <span class="reference-text">Later versions of DOS (since version 6.0) introduced the external <a href="CHOICE_(DOS_command)" class="mw-redirect" title="CHOICE (DOS command)">CHOICE</a> command (in <a href="DR-DOS" title="DR-DOS">DR-DOS</a> also the internal command and <a href="CONFIG.SYS" title="CONFIG.SYS">CONFIG.SYS</a> directive <a href="SWITCH_(CONFIG.SYS_directive)" class="mw-redirect" title="SWITCH (CONFIG.SYS directive)">SWITCH</a>), so, for this specific example application of a menu system, it was no longer necessary to refer to self-modifying batchjobs, however for other applications it continued to be a viable solution.</span>
</li>
<li id="cite_note-NB_DR-DOS_386-13"><span class="mw-cite-backlink">^ <a href="#cite_ref-NB_DR-DOS_386_13-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-NB_DR-DOS_386_13-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text">For example, when running on <a href="I386" title="I386">386</a> or higher processors, later <a href="Novell_DOS_7" class="mw-redirect" title="Novell DOS 7">Novell DOS 7</a> updates as well as <a href="DR-DOS_7.02" class="mw-redirect" title="DR-DOS 7.02">DR-DOS 7.02</a> and higher will dynamically replace some default sequences of 16-bit <code>REP MOVSW</code> ("copy words") instructions in the kernel's runtime image by 32-bit <code>REP MOVSD</code> ("copy double-words") instructions when copying data from one memory location to another (and half the count of necessary repetitions) in order to speed up disk data transfers. <a href="Edge_case" title="Edge case">Edge cases</a> such as odd counts are taken care of.<sup id="cite_ref-Caldera_1997_DOSSRC_11-3" class="reference"><a href="#cite_note-Caldera_1997_DOSSRC-11"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Paul_1997_OD-A3_12-3" class="reference"><a href="#cite_note-Paul_1997_OD-A3-12"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup></span>
</li>
<li id="cite_note-NB_DR-DOS_707-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-NB_DR-DOS_707_15-0">^</a></b></span> <span class="reference-text">As an example, the <a href="DR-DOS" title="DR-DOS">DR-DOS</a> <a href="Master_boot_record" title="Master boot record">MBRs</a> and <a href="Volume_boot_record" title="Volume boot record">boot sectors</a> (which also hold the <a href="Partition_table" class="mw-redirect" title="Partition table">partition table</a> and <a href="BIOS_Parameter_Block" class="mw-redirect" title="BIOS Parameter Block">BIOS Parameter Block</a>, leaving less than 446 respectively 423 bytes for the code) were traditionally able to locate the boot file in the <a href="FAT12" class="mw-redirect" title="FAT12">FAT12</a> or <a href="FAT16" class="mw-redirect" title="FAT16">FAT16</a> file system by themselves and load it into memory as a whole, in contrast to their <a href="MS-DOS" title="MS-DOS">MS-DOS</a>/<a href="PC_DOS" class="mw-redirect" title="PC DOS">PC&nbsp;DOS</a> counterparts, which instead relied on the system files to occupy the first two directory entries in the file system and the first three sectors of <a href="IBMBIO.COM" title="IBMBIO.COM">IBMBIO.COM</a> to be stored at the start of the data area in contiguous sectors containing a secondary loader to load the remainder of the file into memory (requiring <a href="SYS_(DOS_command)" class="mw-redirect" title="SYS (DOS command)">SYS</a> to take care of all these conditions). When <a href="FAT32" class="mw-redirect" title="FAT32">FAT32</a> and <a href="Logical_block_addressing" title="Logical block addressing">LBA</a> support was added, <a href="Microsoft" title="Microsoft">Microsoft</a> even switched to require <a href="Intel_80386" class="mw-redirect" title="Intel 80386">386</a> instructions and split the boot code over two sectors for size reasons, which was not an option for DR-DOS as it would have broken <a href="Backward_compatibility" title="Backward compatibility">backward</a>- and cross-compatibility with other operating systems in <a href="Multi-boot" class="mw-redirect" title="Multi-boot">multi-boot</a> and <a href="Chain_load" class="mw-redirect" title="Chain load">chain load</a> scenarios, as well as with older <a href="IBM_PC_compatible" title="IBM PC compatible">PCs</a>. Instead, the <a href="DR-DOS_7.07" class="mw-redirect" title="DR-DOS 7.07">DR-DOS 7.07</a> boot sectors resorted to self-modifying code, <a href="Opcode" title="Opcode">opcode</a>-level programming in <a href="Machine_language" class="mw-redirect" title="Machine language">machine language</a>, controlled utilization of (documented) <a href="Side_effect_(computer_science)" title="Side effect (computer science)">side effects</a>, multi-level data/code <a href="Instruction_overlapping" class="mw-redirect" title="Instruction overlapping">overlapping</a> and algorithmic <a href="Fold_(function)" class="mw-redirect" title="Fold (function)">folding</a> techniques to still fit everything into a physical sector of only 512 bytes without giving up any of their extended functionality.</span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-HP9100A_1998-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-HP9100A_1998_1-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.hpmuseum.org/hp9100.htm">"HP 9100A/B"</a>. <i>MoHPC - The Museum of HP Calculators</i>. 1998. Overlapped Data and Program Memory / Self-Modifying Code. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20230923125424/https://www.hpmuseum.org/hp9100.htm">Archived</a> from the original on 2023-09-23<span class="reference-accessdate">. Retrieved <span class="nowrap">2023-09-23</span></span>.</cite></span>
</li>
<li id="cite_note-MicroFocus_ALTER-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-MicroFocus_ALTER_2-0">^</a></b></span> <span class="reference-text"><cite class="citation book cs1">"The ALTER Statement". <a rel="nofollow" class="external text" href="https://www.microfocus.com/documentation/visual-cobol/vc80/VS2022/HRLHLHPDF803.html"><i>COBOL Language Reference</i></a>. <a href="Micro_Focus" title="Micro Focus">Micro Focus</a>.</cite></span>
</li>
<li id="cite_note-Push-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-Push_3-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFSpector" class="citation web cs1">Spector, Lee. <a rel="nofollow" class="external text" href="https://faculty.hampshire.edu/lspector/push.html">"Evolutionary Computing with Push: Push, PushGP, and Pushpop"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2023-04-25</span></span>.</cite></span>
</li>
<li id="cite_note-Fosdal_2001-4"><span class="mw-cite-backlink">^ <a href="#cite_ref-Fosdal_2001_4-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Fosdal_2001_4-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFFosdal2001" class="citation web cs1">Fosdal, Lars (2001). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20080421173331/http://www.csd.net/~cgadd/knowbase/DOS0019.HTM">"Self-modifying Batch File"</a>. Archived from <a rel="nofollow" class="external text" href="http://www.csd.net/~cgadd/knowbase/DOS0019.HTM">the original</a> on 2008-04-21.</cite></span>
</li>
<li id="cite_note-Paul_1996-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-Paul_1996_6-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFPaul1996" class="citation book cs1 cs1-prop-foreign-lang-source">Paul, Matthias R. (1996-10-13) [1996-08-21, 1994]. <i>Konzepte zur Unterstützung administrativer Aufgaben in PC-Netzen und deren Realisierung für eine konkrete Novell-LAN-Umgebung unter Benutzung der Batchsprache von DOS</i>. 3.11 (in German). Aachen, Germany: Lehrstuhl für Kommunikationsnetze (<a href="ComNets" title="ComNets">ComNets</a>) &amp; <a href="Institut_f%C3%BCr_Kunststoffverarbeitung" title="Institut für Kunststoffverarbeitung">Institut für Kunststoffverarbeitung</a> (IKV), RWTH. pp.&nbsp;51, <span class="nowrap">71–</span>72.</cite> (110+3 pages, diskette) (NB. Design and implementation of a centrally controlled modular distributed management system for automatic <a href="Client_(computing)" title="Client (computing)">client</a> configuration and <a href="Software_deployment" title="Software deployment">software deployment</a> with <a href="Self-management_(computer_science)" title="Self-management (computer science)">self-healing</a> update mechanism in <a href="Local_area_network" title="Local area network">LAN</a> environments based on <a href="Self-replication" title="Self-replication">self-replicating</a> and indirectly self-modifying batchjobs with zero memory footprint instead of a need for <a href="Terminate_and_stay_resident" class="mw-redirect" title="Terminate and stay resident">resident</a> management software on the clients.)</span>
</li>
<li id="cite_note-Bashe-Buchholz-Hawkins-Ingram-Rochester_1981-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-Bashe-Buchholz-Hawkins-Ingram-Rochester_1981_7-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFBasheBuchholzHawkinsIngram1981" class="citation journal cs1">Bashe, Charles J.; <a href="Werner_Buchholz" title="Werner Buchholz">Buchholz, Werner</a>; Hawkins, George V.; Ingram, J. James; Rochester, Nathaniel (September 1981). <a rel="nofollow" class="external text" href="https://www.ece.ucdavis.edu/~vojin/CLASSES/EEC272/S2005/Papers/IBM-Architecture-Bashe_sep81.pdf">"The Architecture of IBM's Early Computers"</a> <span class="cs1-format">(PDF)</span>. <i><a href="IBM_Journal_of_Research_and_Development" title="IBM Journal of Research and Development">IBM Journal of Research and Development</a></i>. <b>25</b> (5): <span class="nowrap">363–</span>376. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&nbsp;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.93.8952">10.1.1.93.8952</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1147%2Frd.255.0363">10.1147/rd.255.0363</a>. <a href="ISSN_(identifier)" class="mw-redirect" title="ISSN (identifier)">ISSN</a>&nbsp;<a rel="nofollow" class="external text" href="https://search.worldcat.org/issn/0018-8646">0018-8646</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2023-04-25</span></span>. p.&nbsp;365: <q>The SSEC was the first operating computer capable of treating its own stored instructions exactly like data, modifying them, and acting on the result.</q></cite></span>
</li>
<li id="cite_note-Miller_2006-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-Miller_2006_8-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFMiller2006" class="citation web cs1">Miller, Barton P. (2006-10-30). <a rel="nofollow" class="external text" href="https://arcb.csc.ncsu.edu/~mueller/seminar/fall06/miller.html">"Binary Code Patching: An Ancient Art Refined for the 21st Century"</a>. Triangle Computer Science Distinguished Lecturer Series - Seminars 2006–2007. <a href="NC_State_University" class="mw-redirect" title="NC State University">NC State University</a>, Computer Science Department<span class="reference-accessdate">. Retrieved <span class="nowrap">2023-04-25</span></span>.</cite></span>
</li>
<li id="cite_note-Wenzl-Merzdovnik-Ullrich-Weippl_2019-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-Wenzl-Merzdovnik-Ullrich-Weippl_2019_9-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFWenzlMerzdovnikUllrichWeippl2019" class="citation journal cs1">Wenzl, Matthias; Merzdovnik, Georg; Ullrich, Johanna; Weippl, Edgar R. (June 2019) [February 2019, November 2018, May 2018]. <a rel="nofollow" class="external text" href="https://publications.sba-research.org/publications/201906%20-%20GMerzdovnik%20-%20From%20hack%20to%20elaborate%20technique.pdf">"From hack to elaborate technique - A survey on binary rewriting"</a> <span class="cs1-format">(PDF)</span>. <i><a href="ACM_Computing_Surveys" title="ACM Computing Surveys">ACM Computing Surveys</a></i>. <b>52</b> (3). Vienna, Austria: 49:1–49:36 [49:1]. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F3316415">10.1145/3316415</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:195357367">195357367</a>. Article 49. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20210115224807/https://publications.sba-research.org/publications/201906%20-%20GMerzdovnik%20-%20From%20hack%20to%20elaborate%20technique.pdf">Archived</a> <span class="cs1-format">(PDF)</span> from the original on 2021-01-15<span class="reference-accessdate">. Retrieved <span class="nowrap">2021-11-28</span></span>. p.&nbsp;49:1: <q>[…] Originally, <a href="Binary_rewriting" class="mw-redirect" title="Binary rewriting">binary rewriting</a> was motivated by the need to change parts of a program during execution (e.g., run-time patching on the <a href="PDP-1" title="PDP-1">PDP-1</a> in the 1960's) […]</q></cite> (36 pages)</span>
</li>
<li id="cite_note-Knuth_MMIX-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-Knuth_MMIX_10-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFKnuth2009" class="citation web cs1"><a href="Donald_Ervin_Knuth" class="mw-redirect" title="Donald Ervin Knuth">Knuth, Donald Ervin</a> (2009) [1997]. <a rel="nofollow" class="external text" href="https://www-cs-faculty.stanford.edu/~knuth/mmix.html">"MMIX 2009 - a RISC computer for the third millennium"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20211127194354/https://www-cs-faculty.stanford.edu/~knuth/mmix.html">Archived</a> from the original on 2021-11-27<span class="reference-accessdate">. Retrieved <span class="nowrap">2021-11-28</span></span>.</cite></span>
</li>
<li id="cite_note-Caldera_1997_DOSSRC-11"><span class="mw-cite-backlink">^ <a href="#cite_ref-Caldera_1997_DOSSRC_11-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Caldera_1997_DOSSRC_11-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Caldera_1997_DOSSRC_11-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-Caldera_1997_DOSSRC_11-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20210807095409/https://archive.sundby.com/retro/DR-DOS/dossrc.zip">"Caldera OpenDOS Machine Readable Source Kit (M.R.S) 7.01"</a>. <a href="Caldera_(company)" title="Caldera (company)">Caldera, Inc.</a> 1997-05-01. Archived from <a rel="nofollow" class="external text" href="https://archive.sundby.com/retro/DR-DOS/dossrc.zip">the original</a> on 2021-08-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2022-01-02</span></span>.</cite> <a rel="nofollow" class="external autonumber" href="https://web.archive.org/web/20220102102656/https://archive.sundby.com/retro/OpenDOS/OPENDOS_7.01_CODE.ZIP">[1]</a></span>
</li>
<li id="cite_note-Paul_1997_OD-A3-12"><span class="mw-cite-backlink">^ <a href="#cite_ref-Paul_1997_OD-A3_12-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Paul_1997_OD-A3_12-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Paul_1997_OD-A3_12-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-Paul_1997_OD-A3_12-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFPaul1997" class="citation web cs1">Paul, Matthias R. (1997-10-02). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20031004074600/http://www-student.informatik.uni-bonn.de/~frinke/ibmbioa3.zip">"Caldera OpenDOS 7.01/7.02 Update Alpha 3 IBMBIO.COM README.TXT"</a>. Archived from <a rel="nofollow" class="external text" href="http://www.uni-bonn.de/~uzs180/download/ibmbioa3.zip">the original</a> on 2003-10-04<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-03-29</span></span>.</cite> <a rel="nofollow" class="external autonumber" href="https://web.archive.org/web/20181225154705/http://mirror.macintosharchive.org/max1zzz.co.uk/+Windows%20&amp;%20DOS/DOS/System/Novell/Support/Bins/Op702src.zip">[2]</a></span>
</li>
<li id="cite_note-Wilkinson_1996-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-Wilkinson_1996_14-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFWilkinson2003" class="citation web cs1">Wilkinson, William "Bill" Albert (2003) [1996, 1984]. <a rel="nofollow" class="external text" href="https://www.heco.wxwilki.com/h89worm.html">"The H89 Worm: Memory Testing the H89"</a>. <i>Bill Wilkinson's Heath Company Page</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20211213130013/https://www.heco.wxwilki.com/h89worm.html">Archived</a> from the original on 2021-12-13<span class="reference-accessdate">. Retrieved <span class="nowrap">2021-12-13</span></span>. <q>[…] Besides fetching an instruction, the <a href="Z80" class="mw-redirect" title="Z80">Z80</a> uses half of the cycle to <a href="RAM_refresh" class="mw-redirect" title="RAM refresh">refresh</a> the <a href="Dynamic_RAM" class="mw-redirect" title="Dynamic RAM">dynamic RAM</a>. […] since the Z80 must spend half of each <a href="Instruction_fetch" class="mw-redirect" title="Instruction fetch">instruction fetch</a> cycle performing other chores, it doesn't have as much time to fetch an <a href="Instruction_byte" class="mw-redirect" title="Instruction byte">instruction byte</a> as it does a data byte. If one of the <a href="RAM_chip" class="mw-redirect" title="RAM chip">RAM chips</a> at the memory location being accessed is a little slow, the Z80 may get the wrong bit pattern when it fetches an instruction, but get the right one when it reads data. […] the built-in memory test won't catch this type of problem […] it's strictly a data read/write test. During the test, all instruction fetches are from the <a href="ROM" class="mw-redirect" title="ROM">ROM</a>, not from RAM […] result[ing] in the <a href="Heath_H89" class="mw-redirect" title="Heath H89">H89</a> passing the memory test but still operating erratically on some programs. […] This is a program that tests memory by relocating itself through RAM. As it does so, the CPU prints the current address of the program on the <a href="Cathode-ray_tube" title="Cathode-ray tube">CRT</a> and then fetches the instruction at that address. If the RAM ICs are okay at that address, the CPU relocates the test program to the next memory location, prints the new address, and repeats the procedure. But, if one of the RAM ICs is slow enough to return an incorrect bit pattern, the CPU will misinterpret the instruction and behave unpredictably. However, it's likely that the display will lock up showing the address of faulty IC. This narrows the problem down eight ICs, which is an improvement over having to check as much as 32. […] The […] program will perform a worm test by pushing an RST 7 (RESTART 7) instruction from the low end of memory on up to the last working address. The rest of the program remains stationary and handles the display of the current location of the RST 7 command and its <a href="Relocation_(computing)" title="Relocation (computing)">relocation</a>. Incidentally, the program is called a <a href="Computer_worm" title="Computer worm">worm</a> test because, as the RST 7 instruction moves up through memory, it leaves behind a <a href="NOP_trail" class="mw-redirect" title="NOP trail">slime trail</a> of <a href="NOP_(code)" title="NOP (code)">NOPs</a> (NO OPERATION). […]</q></cite></span>
</li>
<li id="cite_note-Ortiz_2015-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-Ortiz_2015_16-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFOrtiz2015" class="citation web cs1">Ortiz, Carlos Enrique (2015-08-29) [2007-08-18]. <a rel="nofollow" class="external text" href="https://weblog.cenriqueortiz.com/computing/2007/08/18/on-self-modifying-code-and-the-space-shuttle-os/">"On Self-Modifying Code and the Space Shuttle OS"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2023-04-25</span></span>.</cite></span>
</li>
<li id="cite_note-Schmidhuber-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-Schmidhuber_17-0">^</a></b></span> <span class="reference-text"><a href="J%C3%BCrgen_Schmidhuber" title="Jürgen Schmidhuber">Jürgen Schmidhuber</a>'s publications on <a rel="nofollow" class="external text" href="https://people.idsia.ch/~juergen/metalearner.html">self-modifying code for self-referential machine learning systems</a></span>
</li>
<li id="cite_note-linux_self_modifying_Paltsev-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-linux_self_modifying_Paltsev_18-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFPaltsev2020" class="citation web cs1">Paltsev, Evgeniy (2020-01-30). <a rel="nofollow" class="external text" href="https://talk.telematika.org/2019/all/self_modifying_code_in_linux_kernel_-_what_where_and_how/">"Self Modifying Code in Linux Kernel - What, Where and How"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2022-11-27</span></span>.</cite></span>
</li>
<li id="cite_note-linux_self_modifying_altinstructions-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-linux_self_modifying_altinstructions_19-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFWieczorkiewicz" class="citation web cs1">Wieczorkiewicz, Pawel. <a rel="nofollow" class="external text" href="https://grsecurity.net/linux_kernel_alternatives">"Linux Kernel Alternatives"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2022-11-27</span></span>.</cite></span>
</li>
<li id="cite_note-Massalin_1992_Synthesis-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-Massalin_1992_Synthesis_20-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFPuMassalinIoannidis1992" class="citation thesis cs1"><a href="Calton_Pu" title="Calton Pu">Pu, Calton</a>; <a href="Henry_Massalin" class="mw-redirect" title="Henry Massalin">Massalin, Henry</a>; Ioannidis, John (1992). <a rel="nofollow" class="external text" href="https://www.scs.stanford.edu/nyu/04fa/sched/readings/synthesis.pdf"><i>Synthesis: An Efficient Implementation of Fundamental Operating System Services</i></a> <span class="cs1-format">(PDF)</span> (PhD thesis). New York, USA: Department of Computer Sciences, <a href="Columbia_University" title="Columbia University">Columbia University</a>. UMI Order No. GAX92-32050<span class="reference-accessdate">. Retrieved <span class="nowrap">2023-04-25</span></span>.</cite> <a rel="nofollow" class="external autonumber" href="https://www.cs.columbia.edu/~library/TR-repository/reports/reports-1992/cucs-039-92.ps.gz">[3]</a></span>
</li>
<li id="cite_note-Henson_2008-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-Henson_2008_21-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFHenson2008" class="citation news cs1"><a href="Valerie_Henson" class="mw-redirect" title="Valerie Henson">Henson, Valerie</a> (2008-02-20). <a rel="nofollow" class="external text" href="https://lwn.net/Articles/270081/">"KHB: Synthesis: An Efficient Implementation of Fundamental Operating Systems Services"</a>. <i>LWN.net</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20210817175159/https://lwn.net/Articles/270081/">Archived</a> from the original on 2021-08-17<span class="reference-accessdate">. Retrieved <span class="nowrap">2022-05-19</span></span>.</cite></span>
</li>
<li id="cite_note-Haeberli_1994_GraficaObscura-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-Haeberli_1994_GraficaObscura_22-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFHaeberliKarsh1994" class="citation web cs1"><a href="Paul_Haeberli" title="Paul Haeberli">Haeberli, Paul</a>; Karsh, Bruce (1994-02-03). <a rel="nofollow" class="external text" href="https://www.graficaobscura.com/future/index.html">"Io Noi Boccioni - Background on Futurist Programming"</a>. <i>Grafica Obscura</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2023-04-25</span></span>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2></div>
<ul><li><cite id="CITEREFÅkesson2013" class="citation web cs1">Åkesson, Linus (2013-03-31). <a rel="nofollow" class="external text" href="https://www.linusakesson.net/programming/gcr-decoding/index.php">"GCR decoding on the fly"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170321014657/https://www.linusakesson.net/programming/gcr-decoding/index.php">Archived</a> from the original on 2017-03-21<span class="reference-accessdate">. Retrieved <span class="nowrap">2017-03-21</span></span>.</cite></li>
<li><cite id="CITEREFBürckert2012" class="citation book cs1 cs1-prop-foreign-lang-source">Bürckert, Christian Felix (2012-03-20). <a rel="nofollow" class="external text" href="https://christian.buerckert.eu/wp-content/uploads/2014/03/Bachelorarbeit.pdf"><i>Eine Bibliothek für Selbstmodifikationen zur Laufzeit in Java</i></a> [<i>A library for self-modifications at runtime in Java</i>] <span class="cs1-format">(PDF)</span> (Thesis) (in German). <a href="Universit%C3%A4t_des_Saarlandes" class="mw-redirect" title="Universität des Saarlandes">Universität des Saarlandes</a>, Naturwissenschaftlich-Technische Fakultät I, Fachrichtung Informatik. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20230818210630/https://christian.buerckert.eu/wp-content/uploads/2014/03/Bachelorarbeit.pdf">Archived</a> <span class="cs1-format">(PDF)</span> from the original on 2023-08-18<span class="reference-accessdate">. Retrieved <span class="nowrap">2023-08-18</span></span>.</cite> (80 pages)</li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="https://asm.sourceforge.net/articles/smc.html">Using self-modifying code under Linux</a></li>
<li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20100717072236/http://public.carnet.hr/~jbrecak/sm.html">Self-modifying C code</a></li>
<li><a rel="nofollow" class="external text" href="https://flint.cs.yale.edu/flint/publications/smc.html">Certified Self-Modifying Code</a></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-03-16" href="https://en.wikipedia.org/wiki/?title=Self-modifying_code&amp;oldid=1280804695">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>